package streamJdk8;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo {

	public static void main(String[] args) {
		ArrayList<Integer> collect = Stream.of(10,5,1,4,6)
				.collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(p -> p))), ArrayList::new));
		
		collect.stream().forEach(t->{
			System.out.println(t);
		});
	}
}
